import axios from "axios";
import { message } from '@/utils/components'

const request = axios.create({
  baseURL: 'http://localhost:5293/api/',
  timeout: 10000
})

request.interceptors.response.use(response => {
  let res = response.data
  if (res.code === 10200) {
    return res

  } else {

    message(res.msg || '无法连接', 'err')
    return Promise.reject(res.msg || '无法连接')
  }
}, err => {
  message('服务器无响应', 'err')
  return Promise.reject(err.message)
})


export default request